package admin.controllers;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.google.appengine.api.blobstore.BlobstoreService;
import com.google.appengine.api.blobstore.BlobstoreServiceFactory;

@SuppressWarnings("serial")
public class ProcessUploadUrlServlet extends HttpServlet {
	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws IOException, ServletException {
		String returnUrl = request.getParameter("returnUrl");
		if (returnUrl != null && returnUrl.length() > 0) {			
			BlobstoreService blobstoreService = BlobstoreServiceFactory
					.getBlobstoreService();
			String uploadUrl = blobstoreService.createUploadUrl(returnUrl);			
			response.setContentType("text/plain");
			response.getWriter().print(uploadUrl);
		}
	}
}
